const http = require("../../../utils/httpUtils.js");
const app = getApp();
Page({
    data: {
        ip: app.globalData.host,
        goodsHot: [],
        height: app.globalData.height,
        showLoc: app.globalData.city
    },
    onLoad(options) {
        this.getVillage(this.data.showLoc);
    },
    getVillage(cityName) {
        http._post('/api/village/index', {
            'city_name': cityName
        }, res => {
            // console.log(res.data)
            wx.stopPullDownRefresh()
            if (res.data.code == 1) {
                this.setData({
                    top_ad: res.data.data.top_ad,
                    home_power: res.data.data.home_power,
                    hotTopic: res.data.data.hotTopic
                })
            }
        })
    },
    detail(e) { //进入详情
        let id = e.currentTarget.dataset.id;
        wx.navigateTo({
            url: `/pages/public/article_detail/article_detail?id=${id}`,
        })
    },
    village(e) { //我为家乡 
        let topic_id = e.currentTarget.dataset.id
        let data = {
            topic_id: topic_id,
            page: 1
        }
        wx.navigateTo({
            url: `/pages/public/village_topic/village_topic?queryData=${JSON.stringify(data)}`,
        })
    },

    getList(e) { //获取分类列表聚合页
        let ac_mark = e.currentTarget.dataset.ac_mark;
        let data = {
            city_name: this.data.showLoc,
            ac_mark: ac_mark,
            page: 1
        }
        wx.navigateTo({
            url: `/pages/public/article_list/article_list?queryData=${JSON.stringify(data)}`,
        })

    },
    search() {
        wx.navigateTo({
            url: `/pages/tabBar/index/search/se`,
        })
    },
    plantingDetail(e) {
        let dataset = e.currentTarget.dataset;
        if (dataset.type == 1) {
            wx.navigateTo({
                url: `/pages/public/article_detail/article_detail?id=${dataset.id}`,
            })
        }
    },
    // 微信分享
    onShareAppMessage() {
        return {
            title: "打造地方最具代表性、独特性的“家乡特色名片"
        }
    },
    onPullDownRefresh() {
        this.getVillage(this.data.showLoc);
    }
})